#pragma once

#include "OrthographicCamera.h"
#include "SubTexture2D.h"
#include "Texture.h"
namespace Hazel
{
class Renderer2D
{
  public:
    static void Init();
    static void Shutdown();

    static void BeginScene(const OrthographicCamera &camera);
    static void EndScene();
    static void Flush();
    // Primitives
    static void DrawQuad(const glm::vec2 &position, const glm::vec2 &size, const glm::vec4 &color);
    static void DrawQuad(const glm::vec3 &position, const glm::vec2 &size, const glm::vec4 &color);


    static void DrawQuad(const glm::vec2 &position, const glm::vec2 &size, const Ref<Texture2D> &texture,
                         float tilingfactor = 1.0f, const glm::vec4 &tilingcolor = glm::vec4(1.0f));
    static void DrawQuad(const glm::vec3 &position, const glm::vec2 &size, const Ref<Texture2D> &texture,
                         float tilingfactor = 1.0f, const glm::vec4 &tilingcolor = glm::vec4(1.0f));
    // subtexture
    static void DrawQuad(const glm::vec2 &position, const glm::vec2 &size, const Ref<SubTexture2D> &subtexture,
                         float tilingfactor = 1.0f, const glm::vec4 &tilingcolor = glm::vec4(1.0f));
    static void DrawQuad(const glm::vec3 &position, const glm::vec2 &size, const Ref<SubTexture2D> &subtexture,
                         float tilingfactor = 1.0f, const glm::vec4 &tilingcolor = glm::vec4(1.0f));


    static void DrawRotatedQuad(const glm::vec2 &position, const glm::vec2 &size, float rotation,
                                const glm::vec4 &color);
    static void DrawRotatedQuad(const glm::vec3 &position, const glm::vec2 &size, float rotation,
                                const glm::vec4 &color);

    static void DrawRotatedQuad(const glm::vec2 &position, const glm::vec2 &size, float rotation,
                                const Ref<Texture2D> &texture, float tilingfactor = 1.0f,
                                const glm::vec4 &tilingcolor = glm::vec4(1.0f));
    static void DrawRotatedQuad(const glm::vec3 &position, const glm::vec2 &size, float rotation,
                                const Ref<Texture2D> &texture, float tilingfactor = 1.0f,
                                const glm::vec4 &tilingcolor = glm::vec4(1.0f));
    // subtexture
    static void DrawRotatedQuad(const glm::vec2 &position, const glm::vec2 &size, float rotation,
                                const Ref<SubTexture2D> &subtexture, float tilingfactor = 1.0f,
                                const glm::vec4 &tilingcolor = glm::vec4(1.0f));
    static void DrawRotatedQuad(const glm::vec3 &position, const glm::vec2 &size, float rotation,
                                const Ref<SubTexture2D> &subtexture, float tilingfactor = 1.0f,
                                const glm::vec4 &tilingcolor = glm::vec4(1.0f));

    struct Statistcs
    {
        uint32_t DrawCalls = 0;
        uint32_t QuadCount = 0;

        uint32_t GetTotalVertexCount()
        {
            return QuadCount * 4;
        }
        uint32_t GetTotalIndexCount()
        {
            return QuadCount * 6;
        }
    };
    static Statistcs GetStats();
    static void ResetStats();

  private:
    static void FlushAndReset();
};
} // namespace Hazel